#include <bits/stdc++.h>
using namespace std;

const long long MIKE = 998244353;

int n, m;
long long ans;
long long q[10000005]; 

int main() { 
    scanf("%d%d", &n, &m);
    if (n > m) swap(n, m); // n <= m
    for(int i = n; i >= 1; i--) { 
        q[i] = 1ll * (n / i) * (m / i);
        for(int j = i + i; j <= n; j += i) { 
            q[i] -= q[j];
        }
        (ans += q[i] * i) %= MIKE;
    }
    printf("%lld\n", ans);
}
